import { BILLTYPE } from '../utils/types';
import { getPages, get, put, del } from '../utils/request';

///获取数据列表
export async function getList(input) {
    switch (input.billType) {
        case BILLTYPE.生产单:
            return getPages(`/app/Production/GetAll`, input.page, input.pageSize, input.queryStr, input.queryKey);
            break;
        case BILLTYPE.入库单:
            return getPages(`/app/Warehouse/GetAll`, input.page, input.pageSize, input.queryStr, input.queryKey, input.billType);
            break;
        case BILLTYPE.出库单:
            return getPages(`/app/Warehouse/GetAll`, input.page, input.pageSize, input.queryStr, input.queryKey, input.billType);
            break;
    }
}
///删除
export async function remove(id) {
    return del(`/app/Task/Delete?id=${id}`);
}
///获取列名
export async function getClmConfig(input) {
    switch (input.billType) {
        case BILLTYPE.生产单:
            return [
                {
                    title: '任务号',
                    dataIndex: 'id',
                    key: 'id',
                    // render: text => <a href={"#/task/detail/" + text}> {text}</a >,
                },
                {
                    title: '生产线',
                    dataIndex: 'targetName',
                    key: 'targetName',
                },
                {
                    title: '产品名称',
                    dataIndex: 'matName',
                    key: 'matName',
                },
                {
                    title: '产量',
                    dataIndex: 'actNum',
                    key: 'actNum',
                },
                {
                    title: '状态',
                    dataIndex: 'dlcName',
                    key: 'dlcName',
                },
                {
                    title: '批次',
                    dataIndex: 'lotNo',
                    key: 'lotNo',
                },
                {
                    title: '负责人',
                    dataIndex: 'manageUserName',
                    key: 'manageUserName',
                },
                {
                    title: '完成期限',
                    dataIndex: 'deadLine',
                    key: 'deadLine',
                    render: date => <span>{new Date(date).toLocaleDateString()}</span>
                },
                {
                    title: '开始时间',
                    dataIndex: 'beginDate',
                    key: 'beginDate',
                    render: date => <span>{new Date(date).toLocaleDateString()}</span>
                },
                {
                    title: '完成时间',
                    dataIndex: 'overDate',
                    key: 'overDate',
                    render: date => <span>{new Date(date).toLocaleDateString()}</span>
                },
                // {
                //     title: '产品编码',
                //     dataIndex: 'matId',
                //     key: 'matId',
                // },
                {
                    title: '摘要',
                    dataIndex: 'description',
                    key: 'description',
                },
            ];
            break;
        case BILLTYPE.入库单:
            return [
                {
                    title: '任务号',
                    dataIndex: 'id',
                    key: 'id',
                    // render: text => <a href={"#/task/detail/" + text}> {text}</a >,
                },
                {
                    title: '入库仓库',
                    dataIndex: 'targetName',
                    key: 'targetName',
                },
                {
                    title: '状态',
                    dataIndex: 'dlcName',
                    key: 'dlcName',
                },
                {
                    title: '负责人',
                    dataIndex: 'manageUserName',
                    key: 'manageUserName',
                },
                {
                    title: '完成期限',
                    dataIndex: 'deadLine',
                    key: 'deadLine',
                    render: date => <span>{new Date(date).toLocaleDateString()}</span>
                },
                {
                    title: '开始时间',
                    dataIndex: 'beginDate',
                    key: 'beginDate',
                    render: date => <span>{new Date(date).toLocaleDateString()}</span>
                },
                {
                    title: '完成时间',
                    dataIndex: 'overDate',
                    key: 'overDate',
                    render: date => <span>{new Date(date).toLocaleDateString()}</span>
                },
                {
                    title: '摘要',
                    dataIndex: 'description',
                    key: 'description',
                },
            ];
            break;
        case BILLTYPE.出库单:
            return [
                {
                    title: '任务号',
                    dataIndex: 'id',
                    key: 'id',
                    // render: text => <a href={"#/task/detail/" + text}> {text}</a >,
                },
                {
                    title: '出库仓库',
                    dataIndex: 'targetName',
                    key: 'targetName',
                },
                {
                    title: '状态',
                    dataIndex: 'dlcName',
                    key: 'dlcName',
                },
                {
                    title: '负责人',
                    dataIndex: 'manageUserName',
                    key: 'manageUserName',
                },
                {
                    title: '完成期限',
                    dataIndex: 'deadLine',
                    key: 'deadLine',
                    render: date => <span>{new Date(date).toLocaleDateString()}</span>
                },
                {
                    title: '开始时间',
                    dataIndex: 'beginDate',
                    key: 'beginDate',
                    render: date => <span>{new Date(date).toLocaleDateString()}</span>
                },
                {
                    title: '完成时间',
                    dataIndex: 'overDate',
                    key: 'overDate',
                    render: date => <span>{new Date(date).toLocaleDateString()}</span>
                },
                {
                    title: '摘要',
                    dataIndex: 'description',
                    key: 'description',
                },
            ];
            break;
    }
}